package com.example.a22310.myapplication.Beans;


import android.content.Intent;
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.example.a22310.myapplication.Activity.MainActivity;
import com.squareup.picasso.Picasso;

import java.io.Serializable;
import java.util.List;

import static com.example.a22310.myapplication.GloableClass.Yuejian.IMG_URL;

public class VideoComment {

    /**
     * code : 200
     * commentlist : [{"id":"1","videoid":"1","clubid":"1","userid":"1","username":"周鑫","userpic":"1.jpg","content":"很精彩，没有浪费流量。很期待下一个电影也如此精彩","sendtime":"2017：11：01"},{"id":"2","videoid":"1","clubid":"1","userid":"2","username":"段绪宏","userpic":"xh.jpg","content":"白瞎了，这是什么鬼。。。","sendtime":"2017：11：01"},{"id":"3","videoid":"1","clubid":"1","userid":"1","username":"周鑫","userpic":"1.jpg","content":"楼上注意言辞啊，这不好看吗，你是找茬吧","sendtime":"2017：11：01"},{"id":"4","videoid":"1","clubid":"1","userid":"2","username":"段绪宏","userpic":"xh.jpg","content":"一点欣赏都不懂，什么都好看。不乐意和你这低智商说话。。。","sendtime":"2017：11：01"},{"id":"5","videoid":"1","clubid":"1","userid":"1","username":"周鑫","userpic":"1.jpg","content":"一点都不好看","sendtime":"2017：11：01"},{"id":"10","videoid":"1","clubid":"1","userid":"2","username":"段绪宏","userpic":"xh.jpg","content":"段绪宏是煞笔","sendtime":"2017：11：01"},{"id":"11","videoid":"1","clubid":"1","userid":"1","username":"周鑫","userpic":"1.jpg","content":"一点都不好看","sendtime":"2017：11：01"}]
     */

    private int code;
    private List<CommentlistBean> commentlist;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<CommentlistBean> getCommentlist() {
        return commentlist;
    }

    public void setCommentlist(List<CommentlistBean> commentlist) {
        this.commentlist = commentlist;
    }

    public static class CommentlistBean extends BaseObservable implements Serializable {
        /**
         * id : 1
         * videoid : 1
         * clubid : 1
         * userid : 1
         * username : 周鑫
         * userpic : 1.jpg
         * content : 很精彩，没有浪费流量。很期待下一个电影也如此精彩
         * sendtime : 2017：11：01
         */

        private String id;
        private String videoid;
        private String clubid;
        private String userid;
        private String username;
        private String userpic;
        private String content;
        private String sendtime;


        public CommentlistBean() {
        }

        public CommentlistBean(String id,String videoid,String clubid, String userid,
                               String username, String userpic,String content, String sendtime) {
            this.id = id;
            this.videoid = videoid;
            this.clubid=clubid;
            this.userid =userid;
            this.username = username;
            this.userpic = userpic;
            this.content=content;
            this.sendtime = sendtime;

        }
        @BindingAdapter("userpic")
        public static void loadInternetImage(ImageView iv, String userpic) {
            userpic = IMG_URL+userpic;
            Picasso.with(iv.getContext()).load(userpic).into(iv);
        }

        @Override
        public String toString() {
            return "Comment{" +
                    "id='" + id + '\'' +
                    ", videoid='" + videoid + '\'' +
                    ", clubid='" + clubid + '\'' +
                    "userid='" + userid + '\'' +
                    ", username='" + username + '\'' +
                    ", userpic='" + userpic + '\'' +
                    "content='" + content + '\'' +
                    "sendtime='" + sendtime + '\'' +
                    '}';
        }

        public void onItemClick(View view){
            Intent intent=new Intent(view.getContext(),MainActivity.class);
            //往详情传递数据
            VideoComment.CommentlistBean  commentlistBean = new VideoComment.CommentlistBean();
            commentlistBean.setUserid(getUserid());
            commentlistBean.setVideoid(getVideoid());
            commentlistBean.setClubid(getClubid());
            commentlistBean.setUsername(getUsername());
            commentlistBean.setUserpic(getUserpic());
            commentlistBean.setContent(getContent());
            commentlistBean.setSendtime(getSendtime());
            intent.putExtra("comment",commentlistBean);
            view.getContext().startActivity(intent);
        }

        @Bindable

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getVideoid() {
            return videoid;
        }

        public void setVideoid(String videoid) {
            this.videoid = videoid;
        }

        public String getClubid() {
            return clubid;
        }

        public void setClubid(String clubid) {
            this.clubid = clubid;
        }

        public String getUserid() {
            return userid;
        }

        public void setUserid(String userid) {
            this.userid = userid;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getUserpic() {
            return IMG_URL+userpic;
        }

        public void setUserpic(String userpic) {
            this.userpic = userpic;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public String getSendtime() {
            return sendtime;
        }

        public void setSendtime(String sendtime) {
            this.sendtime = sendtime;
        }
    }
}

